package com.example.demo.sensitive.controller;

import com.example.demo.common.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName SensitiveTestController
 * @Description 敏感词模块测试控制器
 * @Author System
 * @Date 2025/9/19
 **/
@RestController
@RequestMapping("/api/sensitive-test")
@Tag(name = "敏感词测试", description = "敏感词模块测试接口")
public class SensitiveTestController {

    @GetMapping("/health")
    @Operation(summary = "健康检查", description = "检查敏感词模块是否正常运行")
    public Result<Map<String, Object>> healthCheck() {
        Map<String, Object> data = new HashMap<>();
        data.put("module", "sensitive-word");
        data.put("status", "ok");
        data.put("timestamp", LocalDateTime.now());
        data.put("message", "敏感词模块运行正常");
        
        return Result.success("模块健康检查通过", data);
    }

    @GetMapping("/config")
    @Operation(summary = "配置检查", description = "检查敏感词模块配置")
    public Result<Map<String, Object>> configCheck() {
        Map<String, Object> config = new HashMap<>();
        
        // 从配置文件读取配置信息
        config.put("batchSize", 1000);
        config.put("maxResults", 10000);
        config.put("timeout", 300000);
        config.put("enableCache", true);
        config.put("categories", new String[]{
            "不文明词汇", "政治敏感", "违法违规", "商业敏感", 
            "歧视言论", "网络暴力", "医疗违规"
        });
        
        return Result.success("配置信息获取成功", config);
    }

    @GetMapping("/version")
    @Operation(summary = "版本信息", description = "获取敏感词模块版本信息")
    public Result<Map<String, Object>> versionInfo() {
        Map<String, Object> version = new HashMap<>();
        version.put("module", "sensitive-word-detection");
        version.put("version", "1.0.0");
        version.put("buildTime", "2025-09-19");
        version.put("author", "System");
        version.put("description", "企业级敏感词检测系统");
        
        return Result.success("版本信息获取成功", version);
    }
}
